package com.zjj.learn.javaplus.pkg06.demo601;

import java.util.function.Supplier;

public class TestDemo601_1 {

    public static void main(String[] args) {
        Car car = Car.create(Car::new);
        System.out.println("car = " + car);

        System.out.println();
    }

    public static class Car {
        public static Car create(final Supplier<Car> supplier) {
            return supplier.get();
        }

        public static void collide(final Car car) {
            System.out.println("Collided " + car.toString());
        }

        public void follow(final Car another) {
            System.out.println("Following the " + another.toString());
        }

        public void repair() {
            System.out.println("Repaired " + this.toString());
        }
    }


}
